<?php
/**
 * 插件名称
 * @var string
 */
$self_tag_name = 'editor';

/**
 * 插件类型
 * @var string "function", "block", "compiler" and "modifier". 
 */
$smarty_plus_type = 'compiler';

/**
 * 如果进入编辑状态，则加载编辑器
 * @param $source
 * @param $smarty
 */
function smarty_compiler_editor($source, &$smarty){
	return '<?php smarty_compiler_editor_exec(); ?>';
}

function smarty_compiler_editor_exec(){
	if(isset($_GET['edit']) && trim($_GET['edit']) == '1'){
		//验证权限
		
		//如果开启了编辑
		$smarty = Viewer::get_view();
		$smarty->assign(array(
			'main_domain' => MAIN_DOMAIN,
			'site_id' => SITE_ID,
			'cache_url' => CACHE_URL,
			'app' => APP,
			'act' => ACT,
		));
		if(isset($_REQUEST['tpl_id'])){
			$smarty->assign('tpl', trim($_REQUEST['tpl_id']));
		}
		$smarty->template_dir = ROOT_PATH . '/protected/web/manager/template/yu_editor/';
		$smarty->display('editor.' . TEMPLATE_TYPE);
		$smarty->free();
	}
}